// pages/driver/evaluate/evaluate.js
var api = require("../../../api.js"),
    app = getApp();
var handler=require('../../../utils/function.js');
Page({
    /**
     * 页面的初始数据
     */
    data: {
      img: handler.userImg,
        evaluateList: [{
            title: "技术棒",
            count: 5
        }, {
            title: "人超好",
            count: 5
        }, {
            title: "服务好",
            count: 5
        }, {
            title: "驾驶平稳",
            count: 5
        }, {
            title: "有礼貌",
            count: 5
        }, {
            title: "专业",
            count: 5
        }, {
            title: "神准时",
            count: 5
        }, {
            title: "接驾太慢",
            count: 5
        }, ],
        evaluate: [],
        percentage: 0,
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        var that = this;
        wx.showLoading({})
        app.request({
            url: api.order_comment.commentlist,
            method: 'post',
            data: {},
            success: function(rs) {
              wx.hideLoading()
                console.log('代驾人员评论列表', rs);
                that.setData({
                    evaluateList: rs.data.problem,
                    evaluate: rs.data.res.data,
                    percentage: rs.data.percentage,
                })
            }
        })
        /* this.setData({
             evaluate: wx.getStorageSync("evaluate")
         });*/
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {
        var that = this;
        wx.showNavigationBarLoading();
        app.request({
            url: api.order_comment.commentlist,
            method: 'post',
            data: {},
            success: function(rs) {
                that.setData({
                    evaluateList: rs.data.problem,
                    evaluate: rs.data.res.data,
                    percentage: rs.data.percentage,
                });
                wx.hideNavigationBarLoading()
            }
        })
    },
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {
        var that = this;
        // 显示加载图标  
        wx.showNavigationBarLoading();
        var p = 1;
        p = p + 1;
        app.request({
            url: api.order_comment.commentlist,
            method: 'post',
            data: {
                page: p
            },
            success: function(rs) {
                console.log('代驾人员评论列表', rs);
                that.setData({
                    evaluateList: rs.data.problem,
                    evaluate: rs.data.res.data,
                    percentage: rs.data.percentage,
                });
                wx.hideNavigationBarLoading()
            }
        })
    },
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {}
})